<?php
namespace Home\Controller;
class GbController extends CommonController {

	public function test1(){
		$data = import_excel('Public/201807111534823280.xls');
		dump($data);die;
	}

	//将income表中的12数据洗到6上
	public function test2(){
		$res = M('wemediaincome')->where(['status'=>6])->select();
		$media=M('media')->getField('mmid,wid',true);
		$data = M('wemediaincome')->where(['status'=>12])->getField('number,money',true);
		foreach($res as $v){
			if($data[$v['number']]){
				M('wemediaincome')->where(['id'=>$v['id']])->save(['wid'=>$media[$v['wid']],'mid'=>$v['wid'],'grantmoney'=>$data[$v['number']]]);
			}else{
				M('wemediaincome')->where(['id'=>$v['id']])->save(['wid'=>$media[$v['wid']],'mid'=>$v['wid']]);
			}
		}
	}

	public function test333(){
		$income_list12 = M('wemediaincome')->where(['status'=>12])->select();
		$media=M('media')->getField('mmid,wid',true);
		foreach($income_list12 as $v){
			M('wemediaincome')->where(['id'=>$v['id']])->save(['status'=>6,'wid'=>$media[$v['wid']],'mid'=>$v['wid'],'money'=>0,'grantmoney'=>$v['money']]);
		}
	}

	//将income11修改为12
	public function elven_to_2(){
		$res = M('wemediaincome')->where(['status'=>2])->select();
		$data = M('wemediaincome')->where(['status'=>11,'remark'=>['neq',"注册成功赠送20元"]])->getField('number,money',true);
		foreach($res as $v){
			if($data[$v['number']]){
				M('wemediaincome')->where(['id'=>$v['id']])->save(['grantmoney'=>$data[$v['number']]]);
			}
		}
	}

	//将11修改成2
	public function elevn_to_two(){
		$income_list12 = M('wemediaincome')->where(['status'=>11])->select();
		foreach ($income_list12 as $v){
			if($v['remark'] == "注册成功赠送20元"){
				M('wemediaincome')->where(['id'=>$v['id']])->save(['money'=>0,'grantmoney'=>$v['money']]);
			}else{
				M('wemediaincome')->where(['id'=>$v['id']])->save(['status'=>2,'money'=>0,'grantmoney'=>$v['money']]);
			}

		}
	}
}